{% form_theme form '::fields2tab.html.twig' %}
<div class="contentwrapper">
    <div class="heading">
        <h3>Nouveau Session Caisse</h3>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <form id="form_session_caisse" action="" {{ form_enctype(form) }} method="POST" class="form-horizontal seperator">
                    {{ form_row(form.date,{'attr':{'readonly':'readonly'}}) }}
                {{ form_row(form.solde_initial) }}
                    {{form_row(form.caisse)}}
                    {{form_row(form.user)}}
                    {{ form_row(form._token) }}
                    <div style="float: left;width: 90%" class="form-actions">
                        <button onclick="saveSessionCaisse('n')" class="btn btn-info" type="button">Enregistrer et Nouveau</button>
                        <button onclick="saveSessionCaisse('f')" class="btn btn-info" type="button">Enregistrer et Fermer</button>
                        <button onclick="listSessionCaisse()" class="btn" type="button">Retour vers liste</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $('#gds_ventebundle_sessioncaissetype_solde_initial').spinner({
                                step: 1,
                                places: 3,
                                max: 99999999,
                                showOn: 'both'
                            });
                             $('#gds_ventebundle_sessioncaissetype_solde_initial').val('0.000')
                            function saveSessionCaisse(red) {
                                var data = $('#form_session_caisse').serialize()
                                if ($('#form_session_caisse').valid()) {
                                    $.ajax({
                                        type: 'post',
                                        url: '{{ path('gds_session_caisse_new') }}',
                                        data: data + '&red=' + red,
                                        success: function(data) {
                                            $('#div_session_caisse').html(data)
                                        }
                                    })
                                }
                            }
                            function listSessionCaisse() {
                                $.ajax({
                                    type: 'post',
                                    url: '{{ path('gds_session_caisse_list') }}',
                                    success: function(data) {
                                        $('#div_session_caisse').html(data)
                                    }
                                })
                            }
        </script>